package Get4;

use Moose;
use Moose::Util::TypeConstraints;
use HTML::TreeBuilder;

subtype 'HTML::Element::LookDown' => as class_type('HTML::Element');

coerce 'HTML::Element::LookDown'
  => from 'ArrayRef'
  => via { my $ary = shift; my $self = shift @$ary; $self->tree->look_down(@$ary); } ;


has file => (is => 'rw', default => 'file.html');
has tree => (is => 'rw', lazy_build => 1);
has name => (
	     isa => 'HTML::Element::LookDown', 
	     is => 'rw', 
	     coerce => 1, 
	    );

sub _build_tree {
    my($self)=@_;

    HTML::TreeBuilder->new_from_file($self->file);
}


1;

package main;

my $o = Get4->new;


$o->name([$o, id => 'name']);
warn $o->name->as_HTML;
1;
